using System;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
	/// <summary>
	/// Summary description for Common.
	/// </summary>
	public class Common : DbObject
    {
        protected SqlConnection connec;

		// Init
        public Common(SqlConnection Connection)
        {
            connec = Connection;
        }	

		// Them ban ghi hien du lieu toan van
		public void insertFulltext(int ContentID, string Title, string Content,string HeaderLine, int LanguageID, int TypeID)
		{
			int numAffected;
			// create the parameters
			SqlParameter[] parameters =  {	 new SqlParameter("@ContentID", SqlDbType.Int),
											 new SqlParameter("@Title", SqlDbType.NVarChar, 200),
											 new SqlParameter("@HeaderLine", SqlDbType.NVarChar, 4000),
											 new SqlParameter("@Content", SqlDbType.NText),
											 new SqlParameter("@LanguageID", SqlDbType.Int),
											 new SqlParameter("@TypeID", SqlDbType.Int)
										 };	
			// set the values
			parameters[0].Value	= ContentID;
			parameters[1].Value	= Title;
			parameters[2].Value	= HeaderLine;
			parameters[3].Value	= Content;
			parameters[4].Value	= LanguageID;
			parameters[5].Value	= TypeID;
		
			// run the procedure
            RunProcedure("sp_FullText_insertFulltext", parameters, out numAffected, connec);
		}

		// Tim kiem trong bang du lieu toan van
		public DataSet loadFulltext(int LanguageID, string Content)
		{
			// create the parameter
			SqlParameter[] parameters = {new SqlParameter("@LanguageID", SqlDbType.Int, 4),
										 new SqlParameter("@Content", SqlDbType.NVarChar, 200)
										};
			parameters[0].Value = LanguageID;
			parameters[1].Value = Content;

            return RunProcedure("sp_Fulltext_loadFulltext", parameters, "Tb_Fulltext", connec);
		}

	}
}
